<template>
	<view>
		<view class="block">
			<view class="content">
				<view class="orderinfo">
					<view class="row">
						<view class="nominal">订单名称:</view>
						<view class="text">{{orderName}}</view>
					</view>
					<view class="row">
						<view class="nominal">订单金额:</view>
						<view class="text">{{amount}}元</view>
					</view>
				</view>
			</view>
		</view>
		<view class="block">
			<view class="title">
				选择支付方式
			</view>
			<view class="content">
				<view class="pay-list">
					<view class="row" @tap="paytype='alipay'">
						<view class="left">
							<image :src="img_url+'images/pay/alipay.png'"></image>
						</view>
						<view class="center">
							支付宝支付
						</view>
						<view class="right">
							<radio :checked="paytype=='alipay'" color="#f06c7a" />
						</view>
					</view>
					<view class="row" @tap="paytype='wxpay'">
						<view class="left">
							<image :src="img_url+'images/pay/wxpay.png'"></image>
						</view>
						<view class="center">
							微信支付
						</view>
						<view class="right">
							<radio :checked="paytype=='wxpay'" color="#f06c7a" />
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="pay">
			<view class="btn" @tap="doDeposit">立即支付</view>
			<view class="tis">
				点击立即支付，即代表您同意<view class="terms">
					《条款协议》
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				img_url: this.$api.img_url,
				amount: 0,
				orderName: '',
				paytype: 'alipay' //支付类型
			};
		},
		onLoad(e) {
			this.amount = parseFloat(e.amount).toFixed(2);
			this.orderName = '多个商品组合'
			// uni.getStorage({
			// 	key:'paymentOrder',
			// 	success: (e) => {
			// 		if(e.data.length>1){
			// 			this.orderName = '多商品合并支付'
			// 		}else{
			// 			this.orderName = e.data[0].name;
			// 		}
			// 		uni.removeStorage({
			// 			key:'paymentOrder'
			// 		})
			// 	}
			// })
		},
		methods: {
			doDeposit() {
				//模板模拟支付，实际应用请调起微信/支付宝
				uni.showLoading({
					title: '支付中...'
				});
				setTimeout(() => {
					uni.hideLoading();
					uni.showToast({
						title: '支付成功'
					});
					setTimeout(() => {
						uni.redirectTo({
							url: '/pages/user/index'
						});
					}, 300);
				}, 700)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.block {
		width: 94%;
		padding: 0 3% 40rpx 3%;

		.title {
			width: 100%;
			font-size: 13pt;
		}

		.content {
			.orderinfo {
				width: 100%;
				border-bottom: solid 1rpx #eee;

				.row {
					width: 100%;
					height: 90rpx;
					display: flex;
					align-items: center;

					.nominal {
						flex-shrink: 0;
						font-size: 12pt;
						color: #7d7d7d;
					}

					.text {
						width: 70%;
						margin-left: 10rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						font-size: 12pt;
					}
				}
			}

			.pay-list {
				width: 100%;
				border-bottom: solid 1rpx #eee;

				.row {
					width: 100%;
					height: 120rpx;
					display: flex;
					align-items: center;

					.left {
						width: 100rpx;
						flex-shrink: 0;
						display: flex;
						align-items: center;

						image {
							width: 80rpx;
							height: 80rpx;
						}
					}

					.center {
						width: 100%;
						font-size: 11pt;
					}

					.right {
						width: 100rpx;
						flex-shrink: 0;
						display: flex;
						justify-content: flex-end;
					}
				}
			}
		}
	}

	.pay {
		margin-top: 20rpx;
		width: 100%;
		display: flex;
		justify-content: center;
		flex-wrap: wrap;

		.btn {
			width: 70%;
			height: 80rpx;
			border-radius: 80rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			background-color: #f06c7a;
			box-shadow: 0rpx 5rpx 10rpx rgba(0, 0, 0, 0.2);
		}

		.tis {
			margin-top: 10rpx;
			width: 100%;
			font-size: 9pt;
			display: flex;
			justify-content: center;
			align-items: baseline;
			color: #999;

			.terms {
				color: #5a9ef7;
			}
		}
	}
</style>
